package com.bn.commerce.order;

import java.util.List;
import java.util.Map;

import atg.commerce.order.CommerceItem;
import atg.projects.store.order.StoreOrderImpl;

public class BNOrderImpl extends StoreOrderImpl
{
	private boolean billingSameAsShipping;

	public BnGiftWrapCommerceItemImpl getGiftWrap ()
	{
		List<CommerceItem> commerceItems =  getCommerceItems();
		BnGiftWrapCommerceItemImpl bnGiftWrapCommerceItemImpl = null;

		if(commerceItems !=null && commerceItems.size() > 0)
		{
			for (CommerceItem item : commerceItems)
			{
				if(item instanceof BnGiftWrapCommerceItemImpl)
				{
					bnGiftWrapCommerceItemImpl = (BnGiftWrapCommerceItemImpl) item;
					break;
				}
			}
		}
		return bnGiftWrapCommerceItemImpl;
	}

	public BnGiftCardCommerceItemImpl getGiftCard ()
	{
		List<CommerceItem> commerceItems =  getCommerceItems();
		BnGiftCardCommerceItemImpl bnGiftCardCommerceItemImpl = null;

		if(commerceItems !=null && commerceItems.size() > 0)
		{
			for (CommerceItem item : commerceItems)
			{
				if(item instanceof BnGiftCardCommerceItemImpl)
				{
					bnGiftCardCommerceItemImpl = (BnGiftCardCommerceItemImpl) item;
					break;
				}
			}
		}
		return bnGiftCardCommerceItemImpl;
	}

	/**
	 * This method gets the corresponding coupon code that the user entered for the promotion
	 *
	 * @param promotionId
	 * @return
	 */
	public String getCouponCode(String promotionId) {

		return getCouponCodes().get(promotionId);
	}

	public void setCouponCode(String promotionId, String couponCode) {

		Map<String, String> couponCodes = getCouponCodes();
		couponCodes.put(promotionId, couponCode);
	}

	public Map<String, String> getCouponCodes() {

		return (Map<String, String>) getPropertyValue("couponCodes");
	}


	/**
	 * Sets the promotionId/couponCode map
	 *
	 * @param couponCodes
	 */
	public void setCouponCodes(Map<String, String> couponCodes) {

		setPropertyValue("couponCodes", couponCodes);
	}

	public boolean isBillingSameAsShipping() {
		return billingSameAsShipping;
	}

	public void setBillingSameAsShipping(boolean billingSameAsShipping) {
		this.billingSameAsShipping = billingSameAsShipping;
	}


}
